package com.hemerasolutions.v2trainer.model.muscle;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

import com.hemerasolutions.v2trainer.model.base.BaseModel;
import com.hemerasolutions.v2trainer.model.multimedia.Photo;

@Entity
public class Muscle extends BaseModel {
 
	private static final long serialVersionUID = 1L;

    @Column(length = 60)    
	private String name;

    @ManyToOne
    private MuscleGroup muscleGroup;
    
    @OneToOne(cascade=CascadeType.ALL)
    private Photo photo;    


	public Muscle() {
		super();
	}

	public Muscle(MuscleGroup muscleGroup, String name, Photo photo){
		super();
		this.name = name;
		this.photo = photo;
		this.muscleGroup = muscleGroup;
	}
	
	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public Photo getPhoto() {
		return photo;
	}

	public void setPhoto(Photo photo) {
		this.photo = photo;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	

	public MuscleGroup getMuscleGroup() {
		return muscleGroup;
	}

	public void setMuscleGroup(MuscleGroup muscleGroup) {
		this.muscleGroup = muscleGroup;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((muscleGroup == null) ? 0 : muscleGroup.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Muscle other = (Muscle) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (muscleGroup == null) {
			if (other.muscleGroup != null)
				return false;
		} else if (!muscleGroup.equals(other.muscleGroup))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Muscle [id=" + id + ", name=" + name + ", muscleGroup="
				+ muscleGroup + "]";
	}

}
 
